package cz.data.common.support.metadata;

import cz.data.common.support.DataTypeEnum;

public enum OracleDataTypeEnum implements DataTypeEnum {

    VARCHAR("varchar", "变长字符串"),
    CHAR("char", "字符串"),
    NUMBER("number", "数值"),
    DATE("date", "日期"),
    DATETIME("datetime", "日期时间"),
    CLOB("clob", "长文本"),
    BLOB("blob", "二进制"),
    TIMESTAMP("timestamp", "时间戳");

    private final String value;
    private final String title;

    OracleDataTypeEnum(String value, String title) {
        this.value = value;
        this.title = title;
    }

    public String getValue() {
        return value;
    }

    public String getTitle() {
        return title;
    }

    public static OracleDataTypeEnum match(String value) {
        return match(value, VARCHAR);
    }

    public static OracleDataTypeEnum match(String value, OracleDataTypeEnum defaultItem) {
        if (value != null) {
            for (OracleDataTypeEnum item : OracleDataTypeEnum.values()) {
                if (item.getValue().equalsIgnoreCase(value)) {
                    return item;
                }
            }
        }
        return defaultItem;
    }
}
